package com.example.demo.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

public class JDKProxy {

//    public static <T> T getProxy(Class<T> interfaceClass, ICacheAdapter cacheAdapter) throws Exception {
//        InvocationHandler handler = new JDKInvocationHandler(cacheAdapter);
//        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
//        Class<?>[] classes = interfaceClass.getInterfaces();
//        return (T) Proxy.newProxyInstance(classLoader, new Class[]{classes[0]}, handler);
//    }


        public static BaseDomain getInstance(String className) throws Exception {
            Class clazz = Class.forName(className);
            return (BaseDomain)clazz.newInstance();
        }


    public static void main(String[] args) throws Exception{
        Object instance = getInstance("com.example.demo.proxy.StudentDomain");

        System.out.println(instance);

    }

}
